package adminAction;

import dao.BookDao;
import po.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = "/admin/adminAction/ProductDetailServlet")
public class ProductDetailServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String isbn = req.getParameter("isbn");
        Integer chose = Integer.parseInt(req.getParameter("chose"));
        Book book = new Book();
        book.setIsbn(isbn);
        BookDao bookDao = new BookDao();
        Book book1 = bookDao.selectByIsbn(book);
        req.setAttribute("book",book1);
        if (chose!=2) {
            req.getRequestDispatcher("../page/product-detail.jsp").forward(req, resp);
        }else {
            req.getRequestDispatcher("../page/product-edit.jsp").forward(req, resp);
        }
    }
}
